import axios from 'axios'
import { REQURST_URL } from './url'
import { Toast } from 'antd-mobile'
const request = axios.create({
  baseURL: REQURST_URL,
})
// 请求拦截器
request.interceptors.request.use((config) => {
  Toast.loading('加载中...', 0)
  if (config.url.substr(0, 5) === '/user') {
    config.headers.authorization = localStorage.getItem('HKZF_TOKEN')
  }
  return config
})
// 响应拦截器
request.interceptors.response.use((res) => {
  Toast.hide()
  return res
})

export default request
